package com.songlanyun.modules.information.entity;

import com.alibaba.fastjson.JSONArray;
import com.baomidou.mybatisplus.annotation.FieldFill;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler;
import com.songlanyun.common.drive.Increment;
import lombok.Data;
import lombok.EqualsAndHashCode;

import java.util.Date;

/**
 * 资讯
 *
 * @author WuChao
 * @email songlanyun@gmail.com
 * @date 2022-11-18 09:52:58
 */
@EqualsAndHashCode(callSuper = true)
@Data
@TableName(value = "yxt_information", autoResultMap = true)
public class InformationEntity extends Increment {
    private static final long serialVersionUID = 1L;

    /**
     *
     */
    @TableId
    private Long id;
    /**
     * 标题
     */
    private String title;
    /**
     * 分类ID
     */
    private Long classifyId;
    /**
     * 缩略图
     */
    @TableField(typeHandler = JacksonTypeHandler.class)
    private JSONArray thumbnail;
    /**
     * 内容
     */
    private String content;
    /**
     * 序号
     */
    private Integer sort;
    /**
     * 发布者
     */
    private String publisher;
    /**
     * 推荐商品
     */
    @TableField(typeHandler = JacksonTypeHandler.class)
    private JSONArray recommendGoods;
    /**
     * 推荐门店
     */
    @TableField(typeHandler = JacksonTypeHandler.class)
    private JSONArray recommendShops;
    /**
     * 置顶
     */
    private Boolean top;

    /**
     * 是否置顶
     */
    @TableField(exist = false)
    private Boolean stick;

    public Boolean loadStick() {
        return this.stick = this.top && this.topEndTime.getTime() > System.currentTimeMillis();
    }

    /**
     * 置顶结束时间
     */
    private Date topEndTime;
    /**
     * 推荐
     */
    private Boolean recommend;
    /**
     *
     */
    private Long createId;
    /**
     *
     */
    @TableField(fill = FieldFill.INSERT)
    private Date createTime;
    /**
     *
     */
    private Long updateId;
    /**
     *
     */
    @TableField(fill = FieldFill.INSERT_UPDATE)
    private Date updateTime;

}
